package cn.tedu.springmvc.service;

import cn.tedu.springmvc.mapper.UserMapper;
import cn.tedu.springmvc.pojo.entity.User;
import org.apache.catalina.mbeans.UserMBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//声明他是一个service层级对象--》放到spring容器里面进行管理
@Service
public class UserServiceImpl {

    @Autowired
    UserMapper userMapper;

    //查询
    public List<User> getUserAll(){
        //处理业务 查询相关的业务逻辑
        List<User> userAll = userMapper.getUserAll();
        return userAll;
    }

    //新增
    public void saveUser(User user){
        userMapper.insert(user);
    }
    //修改
    public void updateUser(User user){
        userMapper.update(user);
    }
    //删除
    public void deleteUserById(Long userId){
        userMapper.deleteById(userId);
    }
}
